package com.rocksdata.mc.ui.activity;

import android.content.Context;
import android.os.Bundle;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.ctz.commonframe.ui.TitleBarActivity;
import com.ctz.commonframe.ui.widget.AbsAdapter;
import com.ctz.commonframe.ui.widget.AdapterViewHolder;
import com.rocksdata.mc.R;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
import java.util.Arrays;

/**
 * Created by 陈堂正 on 2017/5/27.
 */

@ContentView(R.layout.activity_school_profile)
public class SchoolProfileActivity extends TitleBarActivity {
    @ViewInject(R.id.gv_school_profile)
    private GridView gvSchoolProfile;

    private String[] items = {"学校概况","历史沿袭","重大事件","办学理念","学校风光","教师团队"};
    private int[] itemIcons = {R.mipmap.ic_profile1,R.mipmap.ic_profile2,R.mipmap.ic_profile3,
            R.mipmap.ic_profile4,R.mipmap.ic_profile5,R.mipmap.ic_profile6};


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitleMiddleText("学校概况");

        gvSchoolProfile.setAdapter(new ProfileGridAdapter(this, items));
    }

    private class ProfileGridAdapter extends AbsAdapter<String> {
        public ProfileGridAdapter(Context context, String[] items) {
            super(context, Arrays.asList(items), R.layout.item_profile_grid);
        }

        @Override
        public void convert(AdapterViewHolder holder, String data) {
            TextView name = holder.getView(R.id.tv_profile_item);
            ImageView icon = holder.getView(R.id.iv_profile_icon);
            if(data != null) {
                name.setText(data);
                icon.setImageResource(itemIcons[holder.getPosition()]);
            }
        }
    }
}
